package com.company.service.impl;

import com.company.service.GetNovelDataService;
import org.junit.Test;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Scanner;

public class GetNovelDataServiceImpl implements GetNovelDataService {
    @Override
    public void execute() {
        Scanner input = new Scanner(System.in);
        String novel = "";
        System.out.println("请输入小说名称: ");
        novel= input.next();
        System.out.println("请输入作者: ");
        novel+= input.next();
        System.out.println("请输入简介: ");
        novel+= input.next();
        Writer writer = null;
        try {
            writer = new FileWriter("/Users/l/Desktop/Project/novel.txt");
            writer.write(novel);
            System.out.println("上传成功!");
        } catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            try {
                writer.flush();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
